Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Help needed to save map data into global variables..

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Guest







PostPosted: Sat May 23, 2009 6:09 am    Post subject: Help needed to save map data into global variables.. Reply with quote

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.

Problemwithcode

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

PostPosted: Sat May 23, 2009 6:12 am    Post subject: Reply with quote

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]
_________________
Bannerfordamnation
Back to top
View user's profile Send private message Send e-mail
Calehay
...yeah.
Class B Minstrel



Joined: 07 Jul 2004
Posts: 549

PostPosted: Sat May 23, 2009 7:10 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
New-Gen
Living in Obscurity...




Joined: 08 Apr 2009
Posts: 13
Location: South Africa, Pretoria

PostPosted: Sat May 23, 2009 7:34 am    Post subject: Reply with quote

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

prob1

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

prob2

Even with all the brackets it still gave me the same problem.
Any thoughts?
_________________
Bannerfordamnation
Back to top
View user's profile Send private message Send e-mail
New-Gen
Living in Obscurity...




Joined: 08 Apr 2009
Posts: 13
Location: South Africa, Pretoria

PostPosted: Sat May 23, 2009 8:06 am    Post subject: Reply with quote

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
_________________
Bannerfordamnation
Back to top
View user's profile Send private message Send e-mail
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Sat May 23, 2009 8:43 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat May 23, 2009 10:35 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Tue May 26, 2009 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group