So in my game you earn certain exp with conversations and actions. I currently have this script running to check for level ups (I am completely new to coding)
<<set $hugo.persuadeskill to 1>>\
<<if $hugo.fearscore gte 10 and $hugo.fearscore lt 22>>\
<<set $hugo.intimidateskill to 1>>\
<<if $hugo.detectscore gte 10 and $hugo.detectscore lt 22>>\
<<set $hugo.detectiveskill to 1>>\
<<if $hugo.localtrustscore gte 22 and $hugo.localtrustscore lt 37>>\
<<set $hugo.persuadeskill to 2>>\
<<if $hugo.fearscore gte 22 and $hugo.fearscore lt 37>>\
<<set $hugo.intimidateskill to 2>>\
<<if $hugo.detectscore gte 22 and $hugo.detectscore lt 37>>\
<<set $hugo.detectiveskill to 2>>\
<<if $hugo.localtrustscore gte 37 and $hugo.localtrustscore lt 57>>\
<<set $hugo.persuadeskill to 3>>\
<<if $hugo.fearscore gte 37 and $hugo.fearscore lt 57>>\
<<set $hugo.intimidateskill to 3>>\
<<if $hugo.detectscore gte 37 and $hugo.detectscore lt 57>>\
<<set $hugo.detectiveskill to 3>>\
It’s obnoxious and takes up a lot of room on my passages, and I know there has to be a better way to code it. or at least more concise or compact.
So I would love suggestions.
I would suggest looking into widgets.
I’m not on my PC so I’m not able to write you a widget that’s tested, so this example widget will have to do. It goes something like this:
<<set $args.persuadeskill to 1>>\
<<if $args.fearscore gte 10 and $args.fearscore lt 22>>\
<<set $args.intimidateskill to 1>>\
<<if $args.detectscore gte 10 and $args.detectscore lt 22>>\
<<set $args.detectiveskill to 1>>\
/% The rest of the level up stuff goes here %/
Widgets should be defined in a passage that uses the
widget tag, just like it says in the reference.
After defining the widget, you can then call it with this in your passage:
As you can guess, this levels up
$hugo. This is because
$args is set to whatever object you pass as the first argument. Pass a different character if you want to level them up instead. Or, if Hugo is the only character and I assumed incorrectly, you can continue using
$hugo instead of
$args in the widget, and then you can call it with just
<<levelup>> (no argument).
Thank you! I’ll try it and tinker with it [: Thank you so much!
I cannot seem to get it to work. I put the widget in the story init? is that right?
and then tagged the passage “widget”
and then it tells me macro levelup doesnt exist.
Widgets don’t go into the StoryInit passage; just create a new passage, name it however you like, and tag it “widget”.
Thank you! I misunderstood the concept [: