Is here a way for Table to hold executable function?
Posted: Sun Aug 29, 2010 4:30 pm
I was thinking two different solutions to my problem, but after imlpementing and executing the code, i noticed i had error in my thinking.
Thing is, In my Point n click type adventure game, i have all the locations stored on separate tables called table.
an example of room and the problem could be
room[startroom] = { variable1=1, variable2 = variable3, variable4=function1()}
Variable1=1 work fine and no problem.
Hoever, Variable2=variable3, and variable4=function1() dont work the way i want them to.
Problem is, that because i save the tables as .bin files and then load them to the table as needed. Therefore it means, that at point I am saving the .bin file, it will also choose numbers for variable2 and variable4.
What I am trying to have is that at point in game that player enters the room, variable2 would get numerical value of variable3.
And similarly, when entering the room, i would like function1() to be executed, and then variable4 receive the value of the functions return value.
So is there some way i can have those tables run those functions and variable=variable thing in real time?
For so far only solution is to make some sort of table entry "special=1" and then in code,
if special=1 THEN the stuff i wanted.
Thing is, In my Point n click type adventure game, i have all the locations stored on separate tables called table.
an example of room and the problem could be
room[startroom] = { variable1=1, variable2 = variable3, variable4=function1()}
Variable1=1 work fine and no problem.
Hoever, Variable2=variable3, and variable4=function1() dont work the way i want them to.
Problem is, that because i save the tables as .bin files and then load them to the table as needed. Therefore it means, that at point I am saving the .bin file, it will also choose numbers for variable2 and variable4.
What I am trying to have is that at point in game that player enters the room, variable2 would get numerical value of variable3.
And similarly, when entering the room, i would like function1() to be executed, and then variable4 receive the value of the functions return value.
So is there some way i can have those tables run those functions and variable=variable thing in real time?
For so far only solution is to make some sort of table entry "special=1" and then in code,
if special=1 THEN the stuff i wanted.