Requesting help with understanding functions
The Stalker
17 Nov 2007, 22:50I've read the help documentation, so I won't reiterate what it said about functions (very little). I am unable to get my test function to output a random number from 1 to 20 direclty.
Below are some attempts, and what they resulted in. I would like to know what I'm doing incorrectly.
Test 1:
Test 2:
Test 3:
I know I'm missing something vital, but the help documentation gives no clues. Running the function, and then checking a variable seems to defeat the purpose of using a function.
Below are some attempts, and what they resulted in. I would like to know what I'm doing incorrectly.
Test 1:
typing "test1" will run this script:
Print "You rolled $d20$"
The function d20 looks like this:
change the contents of numeric variable "d20random" to "$rand(1;20)$"
it prints out this:
You rolled
Test 2:
typing test2 runs this script:
Print "You rolled $d20v2$"
The function d20 looks like this:
[other script command: "$rand(1;20)$"]
it prints out this:
You rolled
Test 3:
typing test3 runs this script:
Print You rolled $d20$ %d20random%
The function d20 looks like this:
change the contents of numeric variable "d20random" to "$rand(1;20)$"
it prints out this:
You rolled (random number appears)
I know I'm missing something vital, but the help documentation gives no clues. Running the function, and then checking a variable seems to defeat the purpose of using a function.
The Stalker
18 Nov 2007, 00:43After much looking, I noticed under the "Advanced" section there at the top of the list was what I was looking for! Egg on my face!
Elexxorine
18 Nov 2007, 11:52Hey. Glad you found it yourself. If you need any more help just ask...
The Stalker
19 Nov 2007, 05:22I've been having issues with compiled games not responding to any commands, or invalid key error when attempting to open them. I'm guessing it has to do with the fact I have Japaneses language font sets installed on my system (I noticed the compass buttons are blocks instead of arrows). I don't intend to 'protect' my stuff, just want to prevent players from cheating.
FYI my join date is correct, every once in awhile I attempt to try and learn to make IF.. but I keep running into walls. However I've learned the basics of scripting within Second Life, and coming back to Quest things look so much easier now (though I need to take into account differences in the scripting languages). This is in part why I was having issues with functions. ASL needs to explicitly declare the variable that it is outputting.. in LSL (SL's scripting language) this is implied.
FYI my join date is correct, every once in awhile I attempt to try and learn to make IF.. but I keep running into walls. However I've learned the basics of scripting within Second Life, and coming back to Quest things look so much easier now (though I need to take into account differences in the scripting languages). This is in part why I was having issues with functions. ASL needs to explicitly declare the variable that it is outputting.. in LSL (SL's scripting language) this is implied.
Elexxorine
19 Nov 2007, 13:45Yeah, a function has to state when it wants the output. Example:
I'm not sure about the compiling issue as i don't compile or use japanese fonts. Alex should really answer that one.
define function <add>
set <num1; $parameter(1)$>
set <num2; $parameter(2)$>
set numeric <total; %num1% + %num2%>
return <%total%>
set <num1; 0>
set <num2; 0>
end defineThe 'return' script tells it what to be in an expression such as <5 - $add(2; 6)$>. This example would be 5 - (2 + 6 ) = 5 - 8 = -3. Do you understand?I'm not sure about the compiling issue as i don't compile or use japanese fonts. Alex should really answer that one.
The Stalker
20 Nov 2007, 07:03Aye I understand, I just need to adjust to how ASL returns data, or at least where I need to look/place it.
Elexxorine
20 Nov 2007, 11:12Glad I could help. If you need help with anything else, just ask.
The Stalker
21 Nov 2007, 19:38I'm wondering what would be a good way to do a universal turn based timer.
Have a turn timer, then have any duration based effects note the turn time they started, and compare to the time they are supposed to end or have them each run their own count down?
I'm looking at starting off with a minimum of 8. 4 basic stats, incrementing or decrementing each turn. Then there will be status effects that will simply be on/off for x number of turns. This could prove for a very large block of if/then statements in the "after each turn" script running section.
The 4 basic ones I can manage with two sets of flags each, 1 to see if the stat is being effected, and a nested if/then to see if the change is positive or negative (I found out the hard way that two values that interrelate to each other, and having them in the status variables running a script each time they changed, would result in the game crashing as they go into infinite loops).
I thought about using a case, and then giving each timer it's own code: 10 100 1000 ect. However I would then need to put in cases for combinations, and that would require me to think up every possible combination, so I threw that out.
Have a turn timer, then have any duration based effects note the turn time they started, and compare to the time they are supposed to end or have them each run their own count down?
I'm looking at starting off with a minimum of 8. 4 basic stats, incrementing or decrementing each turn. Then there will be status effects that will simply be on/off for x number of turns. This could prove for a very large block of if/then statements in the "after each turn" script running section.
The 4 basic ones I can manage with two sets of flags each, 1 to see if the stat is being effected, and a nested if/then to see if the change is positive or negative (I found out the hard way that two values that interrelate to each other, and having them in the status variables running a script each time they changed, would result in the game crashing as they go into infinite loops).
I thought about using a case, and then giving each timer it's own code: 10 100 1000 ect. However I would then need to put in cases for combinations, and that would require me to think up every possible combination, so I threw that out.
Elexxorine
22 Nov 2007, 09:37Create a timer, the action it runs should run a procedure, call it 'count' or something similar. In this procedure, have everythnig you want to happen each second (or whatever). For example put in 'if's for the status effects and 'then' what they do. If you something to count down til say the effect has run out, have a variable that is set to a number when you get the effect, and in the procedure decrease it by 1, after all the varaible stuff, check to see if it's 0, if so turn that effect off. Status effects could be done with flags or a variable (1=on, 0=off) or a proprty on a object for keeping track of them (properties <not burnt>).
Hope this helps.
Hope this helps.