Script to create totem and messages isn't working

Started by Asbestos, November 09, 2014, 08:47:32 PM

Previous topic - Next topic

Asbestos

# totem uprising.crpl
# Created on: 11/9/2014 5:35:56 PM
# ------------------------------------------
delay 3000
CreateMist(CellToPixel(currentCoords) -1 0 0 255)
"totem" CurrentCoords CreateUnit ->unitUID
ClearConversation
AddConversationMessage(1 "Huh. It looks like a totem just popped out of that pool of creeper.")
AddConversationMessage(0 "I didn't know totems were buoyant... weird.")
ShowConversation
PauseGame

The entire script activates on game start, and when I try to unpause it, it just repauses and restarts the script after one frame.

Crimson King

Do you want it to only run once? If so, you need to put everything within a once block.
Try:
# totem uprising.crpl
# Created on: 11/9/2014 5:35:56 PM
# ------------------------------------------
once
delay 3000
CreateMist(CellToPixel(currentCoords) -1 0 0 255)
"totem" CurrentCoords CreateUnit ->unitUID
ClearConversation
AddConversationMessage(1 "Huh. It looks like a totem just popped out of that pool of creeper.")
AddConversationMessage(0 "I didn't know totems were buoyant... weird.")
ShowConversation
PauseGame
endonce


If you need the delay for other things in the code, move the once down between the delay and the CreateMist command.

Remember that once blocks can be used anywhere you want code to only run once.

planetfall

It should also be 3000 delay or delay(3000) instead of delay 3000.
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.