Debugging features

seems like a good way to avoid codish mess while trying to be creative about the content of the dialogue! Thanks!

I think I found a way to combine the text strings and your event-based system.
I could create all my dialogues like
a1="dialogue 1"
a2="dialogue2"

then automate the creation of the following code in some editor like Vim or SublimeText (I would only need to duplicate and increment the numbers).

Of course it would be perfect for linear dialogue, but it could also be easily tweaked when using ASKs, creating branches starting like B1,C1,D1 etc... I'll probably try this☆

1 Like

This just inspired a solution for my own debug problem:

When I'm tracking a variable that isn't calculating right (like an x coordinate that is not drawing where I expect), I currently have to write "log " x variable={x variable}" all over the script.

From now on I'll just have one event called Debug that says

on debug do
debugvar=xvariable
log "debugvar ={debugvar}"
end

Then add this to any spots I want to check:

tell Debug to
call "debug"
end

That will actually save me tons of time and clean up my code. Thanks!

1 Like

Following the same idea, I guess I could have a tile(or an even in the player script?) called "dialog" with an event called "display" which would use the variable txt and I could display a say message everytime with the same code I could just copy and paste :slight_smile: (verbose but easy to maintain, and no need to have a ton of events or variables)

txt = "dialog to display"
tell dialog to
call display
end

I could make the event use the variables txt_x, txt_y, txt_w, txt_h , waitbefore, waitafter
when they are not empty to apply some customization when needed.

※just an idea, not sure it works... but if it works I think It may be the simplest way to do what I am looking for.

It doesn't work because pulp does not stops at the say statement and continue executing the code...
But putting the event in the game script and calling with

tell event.game to
call "dialog"
end

is a smart way to do a lot of things. I will try to find if I can make it work for dialogue though (managing to find a way to "wait for a keypress" before continuing anything else)

Oh! Sorry for the numerous posts with just partial answers!
I finally found a workaround for making long dialogs displaying with minimum code.

This is ugly but you only need to write it once in your room or in the game script.
Here is a working example of how it is written in the same room(change it to a tell event.game call if you write it in the game script)

on enter do
txt1="test1"
txt2="test2"
txt3="test3"
maxtext=3
call "dialogueloop"
end

on dialogueloop do
if endoftext<maxtext then
endoftext+=1
displaytext="txt{endoftext}"
say "{displaytext}" then
call "dialoguesubloop"
end
else
done
end

end

on dialoguesubloop do
if endoftext<maxtext then
endoftext+=1
displaytext="txt{endoftext}"
say "{displaytext}" then
call "dialogueloop"
end
else
done
end
end

To explain the idea, PULP only stops the execution at the end of events, so you need 2 events calling each other in a loop to get the "waiting for keypress" effect!

Yeah, that's the issue with wait. If you use "say...then" it will wait for confirmation...but only for whatever is between "then" and "end."

You can work around this by using event calls as discussed above, but things start getting complicated when you start mixing in functions.

Normally you would add "then call "dialogue2"" to the say event in the dislogue tile, but you don't want dialoguetile to call the event, you want the original tile to call the event. There is a super hacky way to do that: if the dialogue tile is not placed anywhere, it takes the last event.x, event.y that was available, in this case the original tile (this is undocumented, maybe a glitch, but I'm pretty sure this works based on testing).

So you could make the dialoguetile script:

Wait a then
say "txt" then
wait b then
tell event.x, event.y to call "{nexttext}"
end
end
end

and change your original script to

a=
b=
nexttext=[next event name]
tell dialogue to
call "display"
end//(must be end of event)

I think this works, but you can cut out a step and just have dialogueloop call itself.

I used a self-looping function with a wait timer like you described to make the "ding" sounds space out when your score gets updated point-by-point in Playcee's Mod.

1 Like

Wow, making the event call itself works!!! You saved my day (and a couple of others)
Excellent!
I think I could use this kind of self calling events a lot to simulate traditional functions!

And here is the final code :slight_smile:

▼ To put in your room

on enter do
	textindex = 0
	t1 = "test1"
	t2 = "test2"
	t3 = "test3"
	maxtext = 3
	tell event.game to
		call "dialogue"
	end
end

▼ To put in your game script

on dialogue do
	if textindex<maxtext then
		textindex += 1
		displaytext = t{textindex}
		say "{displaytext}" then
			call "dialogue"
		end
	else
		done
	end
end

Oh sorry it doesn't work...
the expression
displaytext = t{textindex}
won't get the value of the variable t1 into the variable displaytext :cold_sweat:

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!

1 Like