Yeah, the {} function only works within quotations and only one iteration (i.e. no "I want to tell you {dialogue{dialoguenumber}}")
Yes, in the end I have to do how you said in the first place... but I can use it as a template and copy/paste it so it is still a fair improvement↓
on enter do
call "t1"
end
on t1 do
say "tatata" then
call "t2"
end
end
on t2 do
say "taratata" then
call "t3"
end
end
And here is the optimized version :
on enter do
call "t1"
end
on next do
say "{txt}" then
call "{nxt}"
end
end
on t1 do
txt="test1"
nxt="t2"
call "next"
end
on t2 do
txt="test2"
nxt="t3"
call "next"
end
on t3 do
done
end
I would strip out the extra events, increment a counter and error check in that “next” event, and lastly call “next” upon itself if it passes the check. That way I’m only creating a series of string variables (t1 to t…) instead of a series of custom events and additional pointer variables every time I want to add dialog.
That is what I intended here but it does not work in PULP because there is no way to call the indexed variables (I would like something like an array here)
No arrays or linked lists in Pulp. But you can do a series of if/then/else statements that only has to be written once in the called game event. This significantly decreases the amount of effort needed to add new dialogue to each room, which would just be setting global variable text in the ‘on enter’ event.
If there is a code snippet of how to do it I would be grateful, because I still struggle to find a way to do it without a series of events or and endless series of encapsulated if/else statements.
Well there's absolutely nothing wrong with your implementation. But I have encountered similar situations where I am adding extra events to every single room, and this is a lot of overhead to have to do as you add more content. Easy to forget or mess up one event.
So for me, I would do something more along these lines.
In a room script:
on enter do
text1="Hello"
text2="How are you"
text3="I am fine."
text4="Cool beans!"
text5="fin"
tell event.game to
call "dialogue"
end
end
in another room script
on enter do
text1="Oh, you again?"
text2="Yeah it's me!"
text3="Hi me."
text4="Hi-C!"
text5="I prefer Hawaiian punch."
text6="That's good stuff but too much sugar."
text7="pffffft"
text8="Bless you"
text9="fin"
tell event.game to
call "dialogue"
end
end
then in my game script
on dialogue do
dialogueCounter++
msg="fin"
if dialogCounter==1 then
msg=text1
elseif dialogCounter==2 then
msg=text2
elseif dialogCounter==3 then
msg=text3
elseif dialogCounter==4 then
msg=text4
elseif dialogCounter==5 then
msg=text5
elseif dialogCounter==6 then
msg=text6
elseif dialogCounter==7 then
msg=text7
elseif dialogCounter==8 then
msg=text8
elseif dialogCounter==9 then
msg=text9
elseif dialogCounter==10 then
msg=text10
end
// can keep adding more here, text11, text12...text20 etc
if msg!="fin" then
say "{msg}" then
wait 0 then
call "dialogue"
end
end
else
counter = 0
text1="fin"
end
end
you could even take it a step further and put the dialogue event call in your game script, and not have to put it in each room
on enter do
wait 0 then
call "dialogue"
end
end
Then a room script would just look like this:
on enter do
text1="Hello"
text2="How are you"
text3="I am fine."
text4="Cool beans!"
text5="fin"
end
I guess your implementation works because of the use of "elseif" while mine used "if/then/end" blocks and ended in an endless series of "end" which was a nightmare.
Since it becomes a lot more simple when using "elseif" I will try that!!!
Thank you very much!