Substring or string manipulation

  1. Describe your reason for requesting this feature. What problems are you running into?

To save on massive if statements it would be great to be able to do left({string variable},5). I have sprites for left and right and need to do the same logic on the sprite. so instead of

if name==hatch-left" then
else if name=="hatch-right" then
else if name=="hatch-up" then
else if name=="hatch-down" then
else if name=="hatch-up-left" then
else if name=="hatch-up-right" then

etc vs

if left(name,5)=="hatch" then

or allow for boolean and compound checks in if statements, OR and AND would save loads of code.

  1. How would this request improve your experience with using Pulp?

Less code written.

  1. Include any other details you have relating to this request.
4 Likes

I believe that this functionality will be available once everyone has access to the SDK (which supports LUA and C), so I'm not sure if this will be a priority for Pulp.

I'm facing the same problem -- huge conditionals just to test if a tile is a member of a set that are clearly labelled.

Being able to get the first n characters of a string would let Pulp scripters do a lot more with this engine, using not just a lot less code, but a lot fewer comparisons.

Suggested design:

tilename = name last_x, last_y
trim tilename, 5 // tilename is now only the first four letters of the tile's name
if tilename == "water" then
  player_pose = "swim"
end
2 Likes