• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Started with LUA, simple trigger not running

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
function OnMapStart()
local u = CreateUnit(Player(0), 'hfoo', 0, 0, 270)
BlzSetUnitName(u, "Footy")
end
function luainit()
TimerStart (CreateTimer(), 00, false, OnMapStart)
end

I just tried to create one unit on map start.
Here is the text I copied to the custom script.

And an I mage below of the Lua Script made with VS code.
 

Attachments

  • ImageA.png
    ImageA.png
    11.1 KB · Views: 41

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,517
Your timer is set to "00". Set it to 0.00.
Also, where are you calling luainit? luainit isn't going to run until you call it.

And you can copy and paste your lua code like so:

[*code=lua]
function OnMapStart()
local u = CreateUnit(Player(0), 'hfoo', 0, 0, 270)
BlzSetUnitName(u, "Footy")
end
function luainit()
TimerStart (CreateTimer(), 00, false, OnMapStart)
end
[*/code]

Remove the asterisks (*)

Lua:
function OnMapStart()
local u = CreateUnit(Player(0), 'hfoo', 0, 0, 270)
BlzSetUnitName(u, "Footy")
end
function luainit()
TimerStart (CreateTimer(), 00, false, OnMapStart)
end
 
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
Lua:
function OnMapStart()
local u = CreateUnit(Player(0), 'hfoo', 0, 0, 270)
BlzSetUnitName(u, "Footy")
end
function luainit()
TimerStart (CreateTimer(), 0.00, false, OnMapStart)
end

  • Start
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: luainit()
So like this, but it's still not working.
 
Level 8
Joined
Jun 16, 2008
Messages
333
You don't need a timer either if its going to be instant. just call the function OnMapStart()

Lua:
function OnMapStart()
local u = CreateUnit(Player(0), FourCC("hfoo"), 0, 0, 270)
BlzSetUnitName(u, "Footy")
end

  • Start
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: OnMapStart()
 
Status
Not open for further replies.
Top