Neat PulpScript features

Say Embeds

Ever used the cool say function? It's pretty neat!

Example:

say “Press the A button!”

Example with sprite:

say “Press the {embed:tileName} button!”

Arrays

Unfortunately Pulp doesn’t support arrays (as of yet). There is a nice little workaround though that will almost make it like you can use arrays!

List example:

on item_0 do
varName = “The first item!”
end
on item_1 do
varName = “The second item!”
end

Call example:

listIndex = 1
call “item_{listIndex}”

Loop example:

listIndex = 0
while listIndex<2 do
call “item_{listIndex}”
log “{varName}”
listIndex++
end

Global classes

Did you know you can request any tile at any moment and use their functions/events WITHOUT showing them on screen? It’s true!

Global example:

tell “tileName” to``
call “aFunctionOfThisTile”
end

Parents and Childs

Normally in code if you have classes that look a lot like each other, you could derive the classes from a parent class containing all functions that they should both have. This reduces code and makes it easier to maintain. PulpScript has a similar feature for it’s tiles and event’s. It’s called mimic.

Mimic example:

parentTileName:

on eventFromParent do
log”hi! I work in both tiles!”
end
on any do
mimic “parentTileName”
end

Mimic with child only functions example:

parentTileName:

on eventFromParent do
log”hi! I work in both tiles!”
end
on any do
mimic “parentTileName”
end
on eventFromChild do
log”hi! I work only from the child tiles”
end

Consistent tile start animation

Last but not least a little trick for tile animations. Normally you would run the following to swap to a different tile.

Inconsistent animation example:

swap “theTileId”

Example with play:

play “theTileId”

Conclusion

That’s all for now folks! PulpScript is already a pretty fun scripting language with lots of interesting features. I’ll be hanging out in the Discord at least till I get my Playdate, so let me know what you think about my article, or if you find any other cool features that I don’t know about!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store