View previous topic :: View next topic |
Author |
Message |
Guest
|
Posted: Sat May 23, 2009 6:09 am Post subject: Help needed to save map data into global variables.. |
|
|
What I want the code to do is to take the (map number) and the (X) and (Y) position of the hero and place it into global variables that can be called back.
My code goes as such:
My global variables are...
global variable (2, Mapnum)
global variable (3, heroxt)
global variable (4, heroyt)
And the part of the code that uses these variables
((Mapnum) == (current map))
((heroxt) == (hero X (me)))
((heroyt) == (hero Y (me)))
Fade screen out
wait (10)
teleport to map (9, 13, 9)
wait (10)
fade screen in
Example: If you are on any map you can press "C" and be taken to a status screen, which is a different map. On the status screen you can then press the exit key and it will teleport you back and place the character in the same X, Y position on the same map that you opened the status screen on.
fade screen out
wait (10)
teleport to map ((Mapnum), (heroxt), (heroyt))
advance textbox
wait (10)
fade screen in
Above is the code used to return from the status screen to the map you opened it up on.
The problem comes in with the saving of the map number into (Mapnum) and the hero's X and Y into (heroxt) and (heroyt). It should save the numbers but instead Hspeak gives me this error.
I've tweaked the code around alot but it still gives me this error. And when I play the game with this implemented code, it opens up the 'Status screen' like it should and exits like it should. But when it returns to the map it puts the hero on (Map 0), position (X-0), (Y-0).
This makes sence because the variables are empty and so it loads those positions.
How can I get it to load the numbers I want it to load and stop giving me this error? |
|
Back to top |
|
 |
New-Gen Living in Obscurity...

Joined: 08 Apr 2009 Posts: 13 Location: South Africa, Pretoria
|
Posted: Sat May 23, 2009 6:12 am Post subject: |
|
|
Sorry I put this up. For some reason when I submitted it it put me on as Guest, even though I was logged in. [New-Gen] _________________
 |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
Posted: Sat May 23, 2009 7:10 am Post subject: |
|
|
Replace:
Code: | ((Mapnum) == (current map))
((heroxt) == (hero X (me)))
((heroyt) == (hero Y (me))) |
with
Code: | ((Mapnum) := (current map))
((heroxt) := (hero X (me)))
((heroyt) := (hero Y (me))) |
":=" sets a variable's value while "==" merely tells the OHR to return a true or false value as to whether the two numbers are equal. _________________ Calehay |
|
Back to top |
|
 |
New-Gen Living in Obscurity...

Joined: 08 Apr 2009 Posts: 13 Location: South Africa, Pretoria
|
Posted: Sat May 23, 2009 7:34 am Post subject: |
|
|
Thanks Calehey.
Alright now my code stands as this
Code: |
(Mapnum) := current map
(heroxt) := hero X (me)
(heroyt) := hero Y (me)
|
Then it gave me this problem
I then tweaked a bit to see what the problem was and when I did this to my code
Code: |
(Mapnum) := current map
#(heroxt) := hero X (me)
#(heroyt) := hero Y (me)
|
It spits out this problem
Even with all the brackets it still gave me the same problem.
Any thoughts? _________________
 |
|
Back to top |
|
 |
New-Gen Living in Obscurity...

Joined: 08 Apr 2009 Posts: 13 Location: South Africa, Pretoria
|
Posted: Sat May 23, 2009 8:06 am Post subject: |
|
|
Haha I just figured it out.
It's actually quite silly of me. I was looking at the script files for one of Fenrir's old games.
If anyone wants to know. You have to use the
set variable (mapnum, currentmap)
comand to get this done.
Thanks anyway _________________
 |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sat May 23, 2009 8:43 am Post subject: |
|
|
Well, using "setvariable()" is not really needed, and I'm pretty sure (just going on a hunch here) that the real problem with Calehay's version of the script is that the parentheses are probably messing with the " := " command. So it should be:
Code: | Mapnum:=currentmap
heroxt:=herox(me)
heroyt:=heroy(me) |
without the parentheses around the variable names. This will save you some typing in the future. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat May 23, 2009 10:35 am Post subject: |
|
|
setvariable has been obsolete for nearly 10 years!
HSpeak's errors are often not helpful. I can see why it gave you that weird second error, but can't think of a simple way to improve it. The first and last errors were totally clear and helpful though. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue May 26, 2009 10:09 am Post subject: |
|
|
I'm tempted to have any direct use of "set variable" throw an "obsolete" warning.... but I guess that would be pushy, so I won't bother :) |
|
Back to top |
|
 |
|