GSE: Sequences, Variables, Macros

GSE: Sequences, Variables, Macros

8M Downloads

GetRandomArgument is gone but the new method doesn't work in GSE.

semisacred opened this issue · 9 comments

commented

with GetRandomArgument gone, I've turned to the following code:

/run local t={"insert something funny","insert something vaguely insulting","insert question re parentage","ask whether they’ve had a blow to the head","etc"}SendChatMessage(t[random(#t)],"YELL")

this works as a normal macro but not in GSE. The lua error:
Message: [string "local t=SendChatMessage(t[random(#t)],"YELL..."]:1: attempt to get length of global 't' (a nil value)

actually, I think the error is that the above code won't save like that and gets shortened to just:
/run local t=SendChatMessage(t[random(#t)],"YELL")

This game is made much more entertaining when I can spout off random shit with a much higher character limit. GSE is a fantastic addon and I thank you very much for it.

commented

It's never going to work in GSE. Its outside the space where GSE can operate. The line is too long and your missing a ;

commented

You could however write this as a Variable.

on the variable part try something like:

function()
  local t={"insert something funny","insert something vaguely insulting","insert question re parentage","ask whether they’ve had a blow to the head","etc"}
  return t[random(#t)]
end

and then in the macro put

/run SendChatMessage("~~VARIBLENAME~~","YELL")

You can test the variable returns a different value by testing the variable in the editor.

commented

See #691 and #726

commented

you might also need to use ' instead of " or matching [[ ]] tags. The use of " might be causing the issue.

commented

thanks for the huge and timely help! so far using the variable is working to an extent. using the test variable gives a random string as expected but when I use the macro it doesn't seem to recalculate the variable if that makes sense. It will select a string randomly but then it will keep giving that same string over and over. I need to tell it to recalculate the variable every time I use the macro somehow. I will experiment with ' and [[ ]] next.

commented

RNG could just be being RNG - It may also be that GSE is "locked" in combat. I use the t[random(#t)] syntax in GSE's random function and it works.

Looking at Lua further there is another syntax of return t[random(1, #t)] that might be more explicit.

commented

/run local t={'insert something funny','insert something vaguely insulting','insert question re parentage','ask whether they’ve had a blow to the head','etc'};SendChatMessage(t[random(#t)],'YELL')

might work as a one liner - i changed the "'s to ' and added in the missing ; It also needs to be a single line when you copy and paste it ensuring the ' are ' and not `

commented

yeah I just can't seem to get anything to properly work. So close with the variable working but just for some reason not randomizing when you actually use the macro. I think I'm actually making this harder than it needs to be. I'll just restructure my macros to be on separate lines and use your random line function. Probably should have done that in the first place. Thanks for the help!

commented

https://youtu.be/Ln2n_pYcpOk

All working after a bit of busywork :P