Hello,
I think this is a pretty basic question but it has me stuck. I'm experimenting with various triggers and scripts but not really anything productive yet. Right now, I am looking at:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8411
I have it functioning as described by the tutorial and that is great. Now, I am trying to figure out how to get the script out of the trigger contents and into my world.lua file. As a start, I'm just trying to move the initial trigger portion over to a file:
When I pull it out of the trigger contents and copy and paste it into a world.lua file, it fails to compile with the following message:
I think that this is referring to the first time [mob_name] is referenced and it would make sense that it is nil when I initially load the script. I just have no idea how to fix it. Any help would be appreciated, even if you could just point me at a post where someone works through this challenge.
Thanks,
Soupy
I think this is a pretty basic question but it has me stuck. I'm experimenting with various triggers and scripts but not really anything productive yet. Right now, I am looking at:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8411
I have it functioning as described by the tutorial and that is great. Now, I am trying to figure out how to get the script out of the trigger contents and into my world.lua file. As a start, I'm just trying to move the initial trigger portion over to a file:
Quote:
killed_mobs = killed_mobs or {} -- make mobs table
mob_name = "%1" -- this mob's name (first wildcard)
-- add this mob if first time
killed_mobs [mob_name] = killed_mobs [mob_name] or { count = 0 }
-- add 1 to count of mobs
killed_mobs [mob_name].count = killed_mobs [mob_name].count + 1
-- remember when we last killed it
killed_mobs [mob_name].last_time = os.time ()
killed_mobs = killed_mobs or {} -- make mobs table
mob_name = "%1" -- this mob's name (first wildcard)
-- add this mob if first time
killed_mobs [mob_name] = killed_mobs [mob_name] or { count = 0 }
-- add 1 to count of mobs
killed_mobs [mob_name].count = killed_mobs [mob_name].count + 1
-- remember when we last killed it
killed_mobs [mob_name].last_time = os.time ()
When I pull it out of the trigger contents and copy and paste it into a world.lua file, it fails to compile with the following message:
Quote:
Error number: 0
Event: Run-time error
Description: [string "Script file"]:5: attempt to index field '?' (a nil value)
stack traceback:
[string "Script file"]:5: in main chunk
Called by: Immediate execution
Error number: 0
Event: Run-time error
Description: [string "Script file"]:5: attempt to index field '?' (a nil value)
stack traceback:
[string "Script file"]:5: in main chunk
Called by: Immediate execution
I think that this is referring to the first time [mob_name] is referenced and it would make sense that it is nil when I initially load the script. I just have no idea how to fix it. Any help would be appreciated, even if you could just point me at a post where someone works through this challenge.
Thanks,
Soupy
