local/global "persistant" variables, in scripts/functions
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Beta-1.2.9 now available!
Can a string be stored as a variable in that way ?
A trip of a thousand leagues starts with a step.
- Montis
- Posts: 340
- Joined: Sun Apr 15, 2012 1:25 am
- Location: Grimrock II 2nd playthrough (hard/oldschool)
Re: Beta-1.2.9 now available!
Sure, you would just need to enclose it in quotation marks.
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Beta-1.2.9 now available!
That's weird, it returns a nil value. I must be doing something wrong...
A trip of a thousand leagues starts with a step.
Re: Beta-1.2.9 now available!
Are you making sure to use a function? If you have it just sitting in a script, it'll try and do everything at the same time.cromcrom wrote:That's weird, it returns a nil value. I must be doing something wrong...
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Beta-1.2.9 now available!
I am sorry, I don't get it so far
1st SE :
"crom_variables"
2nd is whatever, called from a button
it returns 0 while I expect 1...
1st SE :
"crom_variables"
Code: Select all
function setVar(var,number)
var = number
end
function addToVar(var,numbertoadd)
var = var + numbertoadd
end
function subFromVar(var,numbertosub)
var = var - numbertosub
end
try_1 = 0
Code: Select all
function check()
crom_variables.setVar(try_1,1)
print(crom_variables.try_1)
end
A trip of a thousand leagues starts with a step.
- Montis
- Posts: 340
- Joined: Sun Apr 15, 2012 1:25 am
- Location: Grimrock II 2nd playthrough (hard/oldschool)
Re: Beta-1.2.9 now available!
I don't think you can substitute variables that way.
That's why it uses the try_1 value that you set.
That's why it uses the try_1 value that you set.
Re: local/global "persistant" variables, in scripts, in func
just another note on this from a problem I ran into when working on the pit puzzle:
viewtopic.php?f=14&t=3381&start=20#p34449
which will persist across saves, and any other functions that call for namepart will replace it with "pitpuz"
but you cannot actually refer to any placed items, such as:
unless you put it inside a function and put "local " in front of it, so it will just be local to that function
viewtopic.php?f=14&t=3381&start=20#p34449
so, for example, you can have something like:"global" (or "persistent") variables will be stored in save games and the datatypes that are supported in save games is limited. You cannot save tables or variables that contain game objects; they should only be used locally.
Code: Select all
namepart = "pitpuz"
but you cannot actually refer to any placed items, such as:
Code: Select all
thelever = pitpuzlever1
Finished Dungeons - complete mods to play
-
- Posts: 14
- Joined: Sun Feb 24, 2013 5:49 pm
Re: Beta-1.2.9 now available!
@cromcrom try this ....
"crom_variables" - this looks fine
2nd is whatever, called from a button - try the following
Let me know if it works for you
"crom_variables" - this looks fine
2nd is whatever, called from a button - try the following
Code: Select all
function check()
crom_variables.setVar(crom_variables.try_1,1)
print(crom_variables.try_1)
end
Re: local/global "persistant" variables, in scripts/function
are you just kidding? This was five months ago (maybe you didn't notice the dates). I haven't seen him in a while.
Finished Dungeons - complete mods to play
Re: local/global "persistant" variables, in scripts/function
I remember Crom was always disappointed in a lack of feedback.
How did you even find this thread, Hades? lol
How did you even find this thread, Hades? lol
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
- Message me to join in!