Let's say I wanna write a script that refers to a range of npc id's from 6 to 9, but not 0 to 5 or 10 to 999.
so like
if (npc at spot(1,1) == 6 to 9) then (show text box (1))
can it be done?
Is there a way to reference a select range of numbers?
Moderators: marionline, SDHawk
- Gigglyardo
- Slime
- Posts: 9
- Joined: Sun Aug 16, 2015 1:20 am
-
- Slime Knight
- Posts: 260
- Joined: Thu Nov 16, 2017 5:22 am
Re: Is there a way to reference a select range of numbers?
I will share one of my little custom commands. In that example (untested):
Code: Select all
script, var in range, var, min, max, begin
if (var >= min && var <= max) then (return (1))
end
script, yourscript, begin
variable (id)
id := (get npc id (npc at spot(1, 1)))
if (var in range (id, 6, 9)) then (show textbox(1))
end
Do you make love with the same urgency you make games?
-
- Slime Knight
- Posts: 260
- Joined: Thu Nov 16, 2017 5:22 am
Re: Is there a way to reference a select range of numbers?
There's other ways to do it of course.
One way is a switch.
This would also let you choose IDs that aren't all neatly in a range.
One way is a switch.
Code: Select all
script, yourscript, begin
variable (id)
id := (get npc id (npc at spot(1, 1)))
switch (id) do (
case (26, 47, 28, 19) show textbox (1)
)
end
Do you make love with the same urgency you make games?
- Spoonweaver
- Liquid Metal King Slime
- Posts: 6517
- Joined: Mon Dec 08, 2008 7:07 am
- Contact:
Re: Is there a way to reference a select range of numbers?
Gigglyardo wrote: ↑Mon Feb 14, 2022 6:08 pm Let's say I wanna write a script that refers to a range of npc id's from 6 to 9, but not 0 to 5 or 10 to 999.
so like
if (npc at spot(1,1) == 6 to 9) then (show text box (1))
can it be done?
Code: Select all
if (npc at spot(1,1)>=6,and,npc at spot(1,1)<=9) then (show text box (1))
-
- Slime Knight
- Posts: 260
- Joined: Thu Nov 16, 2017 5:22 am
Re: Is there a way to reference a select range of numbers?
Spoon's response is unfortunately invalid. The "npc at spot" command returns an npc reference. Not an ID.
All references are negative numbers and refer to individual instances of npcs on the map. -300 to -1. Therefore, his above code above will always be false.
All references are negative numbers and refer to individual instances of npcs on the map. -300 to -1. Therefore, his above code above will always be false.
Do you make love with the same urgency you make games?
- Gigglyardo
- Slime
- Posts: 9
- Joined: Sun Aug 16, 2015 1:20 am
Re: Is there a way to reference a select range of numbers?
this has been quite helpful and informative
- Spoonweaver
- Liquid Metal King Slime
- Posts: 6517
- Joined: Mon Dec 08, 2008 7:07 am
- Contact:
Re: Is there a way to reference a select range of numbers?
This is true if not missing the point.ArtimusBena wrote: ↑Mon Feb 14, 2022 11:54 pm Spoon's response is unfortunately invalid. The "npc at spot" command returns an npc reference. Not an ID.
All references are negative numbers and refer to individual instances of npcs on the map. -300 to -1. Therefore, his above code above will always be false.
I assumed your example, Gigglyardo, was a for instance example. (as it clearly was)
and the answer was provided in that context to best illustrate the simplest solution to the problem you proposed.
I would assume that if you want to refer to npc's you'd notate them correctly and if you want to refer to npc id's you'd notate that.
You sort of did both and neither in your example, but that's fine as long as you understand that point.
As Artimus has shown though, there is a lot more to the question you asked and indeed a lot more to plotscripting.
Your question honestly begs several other questions in order to really reply in the most helpful way, though we tried not to answer questions with questions. The truth is though, the easiest answer to the question is a simple, Yes.
We generally answer questions on the discord https://discord.gg/gjdhRGkr
I invite you to join with any other questions you may have.