long script inside script box resulting in syntax error

Started by azdesign, August 15, 2013, 05:42:42 am

Previous topic - Next topic

azdesign

[RPG Maker XP]
Hi, I'm stuck on frustrating syntax error that occur whenever I input long script into an event
example code :
$some_variable[:instance].long_function_name('param1','param2',1,2,3)

Put the code into script box and here is how it shows up
$some_variable
[:instance].long_function_name
('param1','param2',1,2,3)

separated into 3 lines aka screw things up
the result is syntax error. I tried to fix it by removing space, putting additional parameter after "," in the line after, etc. But then sometimes it works, sometimes not. 50:50
To be sure that I don't make any mistake with the code, I put the code into a simple short function inside the script and call it from an event and it works, so I'm 100% certain that the mistake was not from my code, but from the script box

So my question is how to properly write long syntax into the script box that run as it should be even after being separated into multiple lines by script box ?

ps : I'm sorry if this is a duplicate topic of a similar problem. I tried searching it first but what I got was about syntax error from specific script someone else's made.  :O.o:
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

winkio

Go into your script editor, and write the following as a new script above main:

module QSC
  def self.sc1
    $some_variable[:instance].long_function_name('param1','param2',1,2,3)
  end
end


Then in the event script call, you can just put

QSC.sc1


If you have more, you can define self.sc2, self.sc3, etc. under the same QSC module.

azdesign

I did that before actually. ", I put the code into a simple short function inside the script and call it from an event and it works,".
Hmm.. so I guess the script box is just like that and can't be helped. I thought it was just a simple word wrap, but apparently it wasn't.
Writing the syntax inside the script editor as a function and call it in the event seems the only way.  :uhm:

Thanks  :haha:
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

KK20

If you truly want it to wrap, you can do this stupid little thing:

class Interpreter
 #--------------------------------------------------------------------------
 # * Script
 #--------------------------------------------------------------------------
 def command_355
   # Set first line to script
   script = @list[@index].parameters[0]
   # Loop
   loop do
     # If next event command is second line of script or after
     if @list[@index+1].code == 655
       # Add second line or after to script
       script += @list[@index+1].parameters[0]
     # If event command is not second line or after
     else
       # Abort loop
       break
     end
     # Advance index
     @index += 1
   end
   script.gsub!(/;/) {"\n"}
   # Evaluation
   result = eval(script)
   # If return value is false
   if result == false
     # End
     return false
   end
   # Continue
   return true
 end
end

All you have to do is make sure you put a semicolon to separate the different script calls. This script call will now work:

$game_party.actors.push($game_actors
[8]);
$game_party.actors[0].name = "Mr.
Orange Hair Guy";$game_party.
gain_gold(
1
0
0
0
)

And of course, notice how I put no semicolon at the end since that's the last essential call. Just only needs to be put in between.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

azdesign

Thanks a lot, this is what I need, gonna try this right away  :D
~ Check out my deviantart http://my-az-design.deviantart.com/ ~