how do you insert to a blank table?
Operation Flashpoint Dragon Rising OFDR Forums :: OPERATION FLASHPOINT: DRAGON RISING :: OFDR EDITING :: EDITING Q+A
Page 1 of 1
how do you insert to a blank table?
I would like someoen to explain how to insert into a blank table?
Before I go on, I have had this explained to me probably about as much times as I've been told, "Units id's get changed when they spawn you plank!"
But nonetheless I get told sooooo much stuff about the code that in goes in one ear and out the other if I don't have a plain english example infront of me.
NOW!
I have a pla unit spawing set on a timer so every 5 seconds another spawns, then I get my position using local x,y,z = OFP:getPosition("mdog").
Now this is ok for the first unit to find out where I am. But what about the rest that spawn after him? I've been trying to get them to update my position ever 3milsecs to no avail. I even did OFP:follow, thinking they would follow me as soon as they spawn. Nope they just run in a straight line towards where my x,y,z position, then follow me.
This might seem like I am detracking from the thread title but I thought maybe inserting the newly spawned units into a blank table might do it, then using a timer to update myposition ever 3 milsecs. So what effectlively happens is when ever a new unit spawns he won't just run in a straight line he'll follow position.
Before I go on, I have had this explained to me probably about as much times as I've been told, "Units id's get changed when they spawn you plank!"
But nonetheless I get told sooooo much stuff about the code that in goes in one ear and out the other if I don't have a plain english example infront of me.
NOW!
I have a pla unit spawing set on a timer so every 5 seconds another spawns, then I get my position using local x,y,z = OFP:getPosition("mdog").
Now this is ok for the first unit to find out where I am. But what about the rest that spawn after him? I've been trying to get them to update my position ever 3milsecs to no avail. I even did OFP:follow, thinking they would follow me as soon as they spawn. Nope they just run in a straight line towards where my x,y,z position, then follow me.
This might seem like I am detracking from the thread title but I thought maybe inserting the newly spawned units into a blank table might do it, then using a timer to update myposition ever 3 milsecs. So what effectlively happens is when ever a new unit spawns he won't just run in a straight line he'll follow position.
Re: how do you insert to a blank table?
yourTable = {} --this is an empty table
I guessed that much but actually coding it correctly.
where does the commands go, how does it get written inconjuction with the rest of the functions?
Guest- Guest
Re: how do you insert to a blank table?
here's my code anyway!
- Code:
zombie_death = 0
zombie_spawn = 0
function onEnter_zone1_mdog()
OFP:addTimer("zombiespawn", 20000)
end
function onEnter_fuelcap_mdog()
OFP:addTimer("fueltimer", 60000)
OFP:displaySystemMessage("stand here to refuel the tanker")
end
function onTimer_zombiespawn()
OFP:removeTimer("zombiespawn")
OFP:spawnEntitySetAtEntityPosition("zombieset","zom")
end
function onTimer_fueltimer()
OFP:removeTimer("fueltimer")
OFP:displaySystemMessage("tanker is full")
end
function onSpawnedReady( setName, setID, tableOfEntities, errorCode )
if setName == "zombieset" then
local x,y,z = OFP:getPosition("mdog")
OFP:rapidMove(tableOfEntities[1],"mdog","OVERRIDE")
OFP:addTimer("zombiespawn",5000)
OFP:addTimer("mdogpos",3000)
end
end
function onTimer_mdogpos()
OFP:removeTimer("mdogpos")
if setName == "zombieset" then
local x,y,z = OFP:getPosition("mdog")
OFP:rapidMove("zombies","mdog","OVERRIDE")
OFP:addTimer("mdogpos",300)
end
end
function onDeath(victim, killer)
if victim == "zombie" then
zombie_death = zombie_death + 1
if zombie_death == 4 then
OFP:removeTimer("zombiespawn")
end
end
end
Re: how do you insert to a blank table?
OK, a couple of things here. You can first use the follow order in the onSpawnedReady and they should follow you. I see where you record your position, but you never use that position to tell them where to go. The rapid move order will use your position as a target, so there's no need to figure out your position anywhere else in the code.
Try this instead in your onSpawnedReady. The position timer should not be necessary at all unless you intend to order them to your position at a set interval or something.
Hope this helps. Get ahold of me on Skype and I'll help explain it a bit more.
Cheers
Try this instead in your onSpawnedReady. The position timer should not be necessary at all unless you intend to order them to your position at a set interval or something.
- Code:
function onSpawnedReady( setName, setID, tableOfEntities, errorCode )
if setName == "zombieset" then
OFP:follow(tableOfEntities[1], "mdog", 1, "OVERRIDE")
OFP:addTimer("zombiespawn",5000)
end
end
Hope this helps. Get ahold of me on Skype and I'll help explain it a bit more.
Cheers
Guest- Guest
Operation Flashpoint Dragon Rising OFDR Forums :: OPERATION FLASHPOINT: DRAGON RISING :: OFDR EDITING :: EDITING Q+A
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum