I'm having two problems with this script. It's a mixture of the script from OHRRPGCE feature requests/suggestions thread and my scripts.
The random number seemed to be returning strange results (results within a range it was not supposed to show), so I wanted to check what randomnumber actually it was. That almost immediately lead to the next problem: displaying a number in a textbox.
I took a look at how to show string var in text box but all I get is a textbox (like in the attached picture) that seems to re-appear as soon as I press space to make it go away.
Code: Select all
script, save_string_variable, var, begin
variable(num)
num:=var
#https://www.slimesalad.com/forum/viewtopic.php?t=7142&highlight=stringvar+textbox
string sprintf(1, $0="Random Number is %d", var)
showtextbox (14) #textbox 14 asks for string_id1
wait for textbox
end
plotscript, RandomTreeText, begin
variable(randomnumber)
randomnumber := random(61-69)
save_string_variable(randomnumber)
showtextbox (randomnumber)
wait for textbox
end
script, RandomStoneText, begin
showtextbox (random (70-75))
wait for textbox
end
script, RandomMushroomText, begin
showtextbox (random (76-79))
wait for textbox
end
plotscript, on keypress handler, begin
variable(x, y, d)
d := hero direction(me)
x := ahead x(hero x(me), d)
y := ahead y(hero y(me), d)
if (keyval(key:space) > 1 || keyval(key:enter) > 1 || keyval(key:ctrl) > 1) then (
if(x >= 0 && x < map width && y >= 0 && y < map height) then(
if(read zone(1, x, y)) then(
# This is a tree!
RandomTreeText
)
#if(read zone(2, x, y)) then(
# # This is a stone!
# RandomStoneText
#)
#if(read zone(3, x, y)) then(
# # This is a mushroom!
# RandomMushroomText
#)
)
)
end
script, ahead x, x, d, dist=1, begin
switch(d) do(
case(left) exit returning(x -- dist)
case(right) exit returning(x + dist)
)
exit returning(x)
end
script, ahead y, y, d, dist=1, begin
switch(d) do(
case(up) exit returning(y -- dist)
case(down) exit returning(y + dist)
)
exit returning(y)
end