I'm learning scripting here with a fishing script. At the moment there is one issue I can't seem to understand or work around.
I have an alias, FISHTO <fishing_dir> that sets a variable
@fishing_dir to <fishing_dir> and then casts the pole
@fishing_dir. So far, so good.
Next, I have a trigger that automatically reels (if necessary), baits the pole and recasts every time I probe it and see there is no bait. The issue appears when I get to the CAST command: the
@fishing_dir is being magickally cleared immediately after my first "CAST" in the FISHTO alias. Can anyone explain why?
Answers
it usually works with the keyword ‘set’ as a regular command
For example: IF @have_fish IS = 1 then REEL otherwise POUT.
I have tried writing everything in quotes, to force it to strings; I've checked for extra spaces where they shouldn't be; Switched IS to ISNOT, just to confirm; tried a greater than approach; tried switching my then/otherwise; and done basically anything I could think of, regardless of whether it made sense or not. I've verified in the Variables tab and with SAY commands in the middle of the script that the variable is actually registering the change, but I can't get the IF statement to ever acknowledge that 1 IS = 1.
if foo = true then say foo is true!
end
'otherwise' is elseif. which in my limited (limited) coding experience usually means you need another true/false statement which means you'd be looking at:
if foo= true then say foo is true!
elseif foo= false then pout.
end
I'm aware there's likely another way, I think (again, limited experience here) using 'not true' to make it so if it comes up as anything other than true it does the elseif statement.
But I don't know how Nexus works as I don't use it myself, but it seems to operate on similar rules as Lua.
You use the If statement
You use the Variable @have_Fish
You use the comparison is and =
You use the Value 1
You use the qualifier - Keep going for condition 1
You use the qualifier - Stop for condition anything else.
You also have to have the right trigger or alias to trigger the comparison of the variable value.
@Ohm : That is, as far as I can tell, exactly what I've been trying to do. Here is a screenshot of the logic and a log, to show how it is working. https://www.dropbox.com/sh/c04csouryspp8gz/AABd-hWNCUXN-MrgYe_VCf2ia?dl=0
Basically, for the purposes of testing I created an endless loop scenario to see if it would ever switch from Then to Otherwise or vice versa. All of the logic is shown the the screencap except for the trigger "Line goes taut", which is working just fine. If the IF block evaluates true it is supposed to reel, and if false then it displays a message stating the @have_fish variable before looping back to reel again. There are other triggers that can change the @have_fish to equal 0, evidence of these at work is shown in the log as well. As the log shows, it always evaluates false, even when set to what should be true.
Like I stated above, I've tryed forcing everything to strings; checking the match case box; flipping various options around; at the end of the day, I simply cannot figure out how to get the IF statement to identify the value 1 with the 1 assigned to the variable.
Right now you are comparing one value to another which will never be true