I'm trying to write a script that sets a cost for each shop item (which are step-on NPCs) in my Zelda game but I'm not sure how to make HS do what I want it to.
Here's what I'm trying to do, I think it's pretty simple:
script, check shop items, begin
while (ref) do (
next := next npc reference(ref)
switch (npc id(ref)) do (
case (20) set item price (30)
case (22) set item price (60)
case (24) set item price (20)
case (28) set item price (50)
case (29) set item price (60)
case (30) set item price (75)
case (34) set item price (90)
)
ref := next
)
subscript, set item price, cost, begin
variable (str)
str := create text
$5=cost
set slice text (str, 5)
set parent (str, get npc slice(ref))
put slice (str, 4, 20)
end
I honestly didn't expect it to work like that, but I'm also not sure how to make the "$5=cost" line work, can't find any documentation on it. That's the line that's throwing an error in hspeak though.
subscript, set item price, cost, begin
variable (str)
str := create text
$5="%d"
string sprintf (5, 5, cost)
set slice text (str, 5)
set parent (str, get npc slice(ref))
put slice (str, 2, 20)
end