I was trying to make a project that lets you create variables, get the values of the variables, and change the values of variables... All in one script! The script I have is pretty long so go get some hot chocolate and prepare yourself. Before we start, I would like to tell you what should happen. If you type a variable that has been made, it will say what its value is. If you type something random, it will make a variable and ask you to set it. If you type a variable name with a _ before it, it will let you change the value of that variable. If you type a non-existing variable with a _ before it, it will give you an error message. OK. Here we go...
when gf clicked forever ask [] and wait set [answer variable v] to (answer) if <not <(letter (1) of (answer variable)) = [_] >> if <not <[variables v] contains (answer)>> add (answer) to [variables v] ask [What should it be set to?] and wait add (answer) to [values v] else set [test v] to (1) if <not < (item (test) of [variables v]) = (answer)>> repeat until <(item (test) of [variables v]) = (answer) change [test v] by (1) end end say (item (test) of [values v]) for (2) secs end else delete [all v] of [answer_list v] set [test v] to (1) repeat (length of (answer variable)) add (letter (test) of (answer variable)) to [answer_list v] change [test v] by (1) set [answer variable v] to () repeat (length of [answer_list v] set [answer variable v] to (join (answer variable)(item (test) of [answer_list v])) change [test v] by (1) end if <[variables v] contains (answer variable v)> set [test v] to [1] repeat until <(item (test) of [variables v]) = (answer variable)> change [test v] by (1) end ask [What would you like the variable to be set to?] and wait replace item (test) of [values v] with (answer) else say [That variable does not exist. Try making it.] for (2) secs end endIt's not working so, um... could you help?
Last edited by PullJosh (2012-03-21 20:45:05)
Offline
I really couldn't understand how you were trying to change the value of a variable, try this:
set [i] to (1) set [name] to [] repeat ((length of (answer variable)) -(1)) change [i] by (1) set [name] to (join (name) (letter (i) of (answer variable))) end if<[variables v] contains (name)> ask [replace with what?] and wait set [i] to (0) repeat (length of [variables v]) if<(item (i) of [variables v]) = (name)> replace item (i) of [values v] with (answer) stop script // or let it run to completion if you want to keep it in one loop. end end else error end
Offline
MoreGamesNow wrote:
I really couldn't understand how you were trying to change the value of a variable, try this:
set [i] to (1) set [name] to [] repeat ((length of (answer variable)) -(1)) change [i] by (1) set [name] to (join (name) (letter (i) of (answer variable))) end if<[variables v] contains (name)> ask [replace with what?] and wait set [i] to (0) repeat (length of [variables v]) if<(item (i) of [variables v]) = (name)> replace item (i) of [values v] with (answer) stop script // or let it run to completion if you want to keep it in one loop. end end else error end
What part do I need to replace it with?
Offline
The final "else" part (setting a variable)
Offline
Ah, I understand now. Unfortunately, in isolation, a script with the same input should result in the same output, so I'm not sure how typing the exact same thing twice would result in different outcomes. Are there any other scripts?
Offline
MoreGamesNow wrote:
Ah, I understand now. Unfortunately, in isolation, a script with the same input should result in the same output, so I'm not sure how typing the exact same thing twice would result in different outcomes. Are there any other scripts?
Nope. I'll post it online you can download it for a bit more... well... a bit better result.
Offline
Actually quite similar to my Scratch Epic Database project I've been working on. Except mine has something more like 2000 blocks of code lol. This should work alright, however I would have to download it and study the scripting a little more, which I will hopefully do later today.
Last edited by prototype47 (2012-03-22 18:02:00)
Offline
Here you go.
Last edited by MoreGamesNow (2012-03-22 18:57:04)
Offline