Post new topic    
Metal Slime
Send private message
How to increase a variable with plotscript? 
 PostWed Aug 07, 2013 1:01 pm
Send private message Reply with quote
Hi,
It feels a bit stupid to ask such a thing, but even thoug using the plotscript dictionary I fail to figure out how to increase a (global) variable. Confused
The compiler tells me that + is not allwed inside a script, and suggested using add, but still the script is not acepted.


I placed the variable under the include part, I hope that's okay.
Code:
global variable (1,stepcounter)
...
plotscript,each step,begin
# global variable can be read and set in any script
stepcounter add 1
show value (stepcounter)

end


Thanks for you help! Grin
Metal King Slime
Send private message
 
 PostWed Aug 07, 2013 1:49 pm
Send private message Reply with quote
Code:
plotscript, each step, begin

    stepcounter += 1

end



That's pretty much it I suppose. Alternatively:

Code:
plotscript, each step, begin

    stepcounter := stepcounter + 1

end

Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Liquid Metal King Slime
Send private message
Re: How to increase a variable with plotscript? 
 PostWed Aug 07, 2013 2:12 pm
Send private message Reply with quote
marionline wrote:
Hi,
The compiler tells me that + is not allwed inside a script, and suggested using add, but still the script is not acepted.


Can you send me a screenshot or a copy-paste of that error message? it sounds wrong.
Metal King Slime
Send private message
 
 PostWed Aug 07, 2013 4:37 pm
Send private message Reply with quote
I think when you use the add command, you're supposed to seperate it from the numbers involved with commas. Like, shouldn't it look like:

Code:
stepcounter,add,1
Liquid Metal King Slime
Send private message
 
 PostWed Aug 07, 2013 5:07 pm
Send private message Reply with quote
I... I don't even remember if Giz is correct.

I think nobody should ever be using the add command directly. Any error message that still recommends it is a bug.
Metal Slime
Send private message
 
 PostWed Aug 07, 2013 5:12 pm
Send private message Reply with quote
That's the Error message I got:


I re-read it and i think it's not saying that I should use add instead of +, so the problem here were a missunderstanding. Still, I'm not sure what the compiler wants to tell me. Sorry. Angel

I'll try out the other sugesstions on how to increase a variable and I'll tell you what worked and what not, maybe we could then add an example to the
plotscript dictionary or the wiki.
Metal King Slime
Send private message
 
 PostWed Aug 07, 2013 5:50 pm
Send private message Reply with quote
It's complaining that "stepcounter + 1" doesn't do anything. Yes, add two numbers together, and then what? The result of the addition is thrown away.

Yes, Giz is right. And trivia: if you don't include plotscr.hsd then you should instead write "add(a, b)"
Metal Slime
Send private message
 
 PostWed Aug 07, 2013 6:04 pm
Send private message Reply with quote
@TMC: Now it makes sense. Thanks! Smile

BMR's version works.
Giz's version seems not to work, the compiler says that 0 arguments are passed to math function add, but it should be always two.

Thanks! Grin
Metal King Slime
Send private message
 
 PostWed Aug 07, 2013 6:29 pm
Send private message Reply with quote
Oh whoops, Giz and I were wrong. I'm thinking of the mod command which has a different form when plotscr.hsd isn't included.
Display posts from previous: