Hey, I need to make an integer property loop, for example: It starts at 1, then I press TAB key, then it adds 1. But when I keep pressing tab, instead of going to 4, it goes back to 1, and repeats. Can anyone tell me how to do that?
yeah, best to do in python, although you can in logic bricks.
ill do a python one as its easier
Add a keyboard sensor called tab (lowercase), make it TAP to stop it sending lots of pulses.
change the “propname” value in this script to the name of the property you want to loop
controller = GameLogic.getCurrentController()
owner = controller.owner
tab = controller.sensors["tab"]
propname = "prop"
if tab.positive:
if owner[propname] < 3:
owner[propname] += 1
else:
owner[propname] = 1
i found the problems.
Firstly, you didnt add the tab sensor to one of the script controllers.
secondly, you changed the name of the gun property in the wrong line! - i had made a variable called “propname” for you to change to make it easier.
What do you want it to do?
(i think there’s a mistake in your setup)
at the moment, it starts and stays on 2
Hello
Logic Brick setup:
Add an “Int” property named loop ( value: 1) to your object, then:
Keyboard Sensor - Tab Key -> AND -> Property Actuator - Prop: loop - Value: 1
Property Sensor - Interval - Prop: loop - Min: 4 Max: 5 -> AND -> Property Actuator - Assign - Prop: loop - Value: 1
Bye