change rule

Hi, i have created a boolean 0 = false and 1= true

how can i change a rule to OFF based on changing values.

if true, change rule to OFF

if false change rule to TRUE

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    change attribute: game.myBoolean To: not(game.myBoolean)

  • sonicm3sonicm3 Member Posts: 141

    sorry i wasnt clear my fault.

    i mean, how can i write a rule that turns off another rule.

  • SocksSocks London, UK.Member Posts: 12,822

    @sonicm3 said:
    how can i write a rule that turns off another rule.

    You can't directly switch a rule off (that's to say, you can't disable it so it's ignored), but you can give a rule a condition - or wrap it in another rule - that it needs to meet in order for it to run.

    So for example if you have a rule that says:

    If High-score is higher than 10,000
    --Change bonus to bonus+50
    --Change colour to gold

    And you wanted to disable the rule, then you'd simply wrap it in another rule like this . . .

    If X is true
    --If High-score is higher than 10,000
    ----Change bonus to bonus+50
    ----Change colour to gold

    So, now by changing X to either 1 or 0 (true or false) you can switch the whole rule on or off.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Watch my GSlogic series or my video how rules work.....

  • sonicm3sonicm3 Member Posts: 141

    Socks thankyou very much and also lost_

    You guys gave me a great workaround. Can you tell me how i can write this command properly.

    IF game.rules is True
    DO
    *make the actor invisible

    I think its via graphics, but not sure the command.
    something like.. self.graphics.visibleFALSE or -1 ?

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 if game.rules is true change attribute self.color.alpha to 0

  • sonicm3sonicm3 Member Posts: 141

    Thanks icebox. That worked great, but it didnt solve my issue, i thought it would ahh!

    My problem is, when im dragging an actor with my mouse during the game testing, if i hit another actor it moves it around. Im trying to look for a way where i can disable actor1s physics so when im moving actor2 it doesnt knock it off the platform, but still shows the actor.

    Ive code all the code done ect for moving changing the boolean true and false, but need some way i can add to make actor1 disabled.

    If game.rules is TRUE
    DO
    SOMETHING HERE to make this actor disabled until my other actor changed the attribute back to false

  • IceboxIcebox Member Posts: 1,485
    edited April 2016

    @sonicm3 said:
    My problem is, when im dragging an actor with my mouse during the game testing, if i hit another actor it moves it around. Im trying to look for a way where i can disable actor1s physics so when im moving actor2 it doesnt knock it off the platform, but still shows the actor.

    Switch moveable off on actor 2 so it doesn't get knocked off

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2016

    @sonicm3 said:
    Can you tell me how i can write this command properly.

    IF game.rules is True
    DO
    *make the actor invisible

    I think its via graphics, but not sure the command.
    something like.. self.graphics.visibleFALSE or -1 ?

    Unfortunately you can't switch an actor's 'visible' attribute on or off at runtime (while the game is running).

    But you can make the actor invisible in various other ways, change its size to 0 x 0, change its alpha channel value to 0 or move the actor off scene and so on.

    So . . .

    When game.rule is true
    --Change self.colour.alpha to 0

    When game.rule is true
    --Change size width to 0
    --Change size height to 0

    When game.rule is true
    --Change x position to -400

    . . . etc.

    They'll all have the effect of the actor instantly dissapearing from the scene.

  • sonicm3sonicm3 Member Posts: 141

    Thanks both of you, PERFECT!!!

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    guys just really quickly, how would i write a command to turn moveable off?

    DO
    self.physics.movable to : false? or 0 ?

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 said:
    guys just really quickly, how would i write a command to turn moveable off?

    You cant turn moveable off during gameplay , you can keep moveable on and give the actor high density , maybe 100 + it will keep it from moving , or you can constrain its position so that it doesnt move.

  • sonicm3sonicm3 Member Posts: 141

    thats a great idea, yeah done that, thanks alot mate, appreciate it alot.

Sign In or Register to comment.