[ACE][SCRIPTING] JUST TRYING TO EDIT IN AN "ON/OFF SWITCH" TO A SNIPPET

Posts

Pages: 1
So I stumbled across this snippet, which I think I may have use for. It's a pretty straightforward script that makes the player move tile by tile. However, I would like the ability to toggle it off and on. It's come to my attention that there's no "general way" to do this, but trying things out on my own despite my severe lack of scripting knowledge, with information I've gathered here and here, the furthest I think I've got was the following:

At the top:
module MGCtile

Script = true
end

if [MGCtile::Script] == true && $game_switches[2]


At the bottom:
else

end
end


Luckily it didn't crash anything (no seriously, like why didn't I come here first?), but all this edit really did was disable the script outright, regardless of what switch I put in. Again I'm definitely not a scripter, this was all just me seeing if I could luck out with what I could find on the net here and there.

In any case, any input you can offer should be of help. Feel free to take a look at the snippet above to see if it's a complex task or not (I personally don't really have a frame of reference haha.) If you have any suggestions for edits, workarounds, or even alternate approaches I'd be willing to listen!

As always, thanks for your time!
You would have to go through each method and call an alias if the switch is on
For example:
change

#--------------------------------------------------------------------------
# * Get Screen X-Coordinates
#--------------------------------------------------------------------------
def screen_x
$game_map.adjust_x(@x) * 32 + 16
end


to:

#--------------------------------------------------------------------------
# * Get Screen X-Coordinates
#--------------------------------------------------------------------------
alias old_screen_x screen_x
def screen_x
if $game_switches[2]
$game_map.adjust_x(@x) * 32 + 16
else
old_screen_x
end
end


tbh I'm not sure if that even works lol but I think it should, but that's quite tedious. There might be a better way to do it not sure.
author=Quasi
You would have to go through each method and call an alias if the switch is on
tbh I'm not sure if that even works lol but I think it should, but that's quite tedious. There might be a better way to do it not sure.
Thanks for the reply! I'll go ahead and give it a shot, luckily we're only dealing with a snippet instead of a full fledged script-system, so the tedious bits should be manageable enough! I'll let you know how it goes! :)

EDIT: Just back from my first attempt, got some 'unexpected $end' errors so I think I'm gonna have another go at it. Though before that I think I'm gonna look up what an alias actually does haha)
That error usually means you have an extra end laying around.
Also when you get to a def with parameters don't forget to include them in the alias call, like:

alias old_update_scroll update_scroll
def update_scroll(last_real_x, last_real_y)


the alias call would be

old_update_scroll(last_real_x, last_real_y)
Pages: 1