Damienknight Posted March 11, 2015 Share Posted March 11, 2015 (I posted this under the Tutorial thread, but thought it might fit better here). I cannot get any .lua based mods to work. Specifically I tried the dry towels mod, and couple attempts at modding myself. Here is the simple intro mod (that for me does nothing): function sayHello()playerlog = getSpecificPlayer(0);playerlog.Say("Hello");end Events.EveryTenMinutes.Add(sayHello); I placed this inside of my mods folder %%Zomboid\mods\helloworld\media\lua I setup the mod.info and poster.png in the helloworld root folder. The mod info file: name=Hello World (1.0.0)poster=poster.pngdescription=Test where player 0 says Hello World every 10 in game minutesid=helloworldurl=www.google.com When booting, the mod appears in the mod list, with poster working. I double click to activate (checkmark appears). I start a Beginner survival game. I would expect to have my character say 'Hello' every 10 minute in game interval. Any advice? Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 11, 2015 Share Posted March 11, 2015 What is playerlog? Link to comment Share on other sites More sharing options...
Damienknight Posted March 12, 2015 Author Share Posted March 12, 2015 What is playerlog?A variable i am creating, which points to a player, whom I want to force to Say things. Link to comment Share on other sites More sharing options...
blindcoder Posted March 13, 2015 Share Posted March 13, 2015 There's a subtle error in your script.You need to use "player:Say("Hello");" instead of "player.Say("Hello");".The difference is a colon ( instead of a dot (.) between player and Say. EnigmaGrey 1 Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 13, 2015 Share Posted March 13, 2015 There's a subtle error in your script. You need to use "player:Say("Hello");" instead of "player.Say("Hello");". The difference is a colon ( instead of a dot (.) between player and Say.This is why I shouldn't post after waking up, BlindCoder. Totally missed it. Link to comment Share on other sites More sharing options...
Damienknight Posted March 13, 2015 Author Share Posted March 13, 2015 There's a subtle error in your script.You need to use "player:Say("Hello");" instead of "player.Say("Hello");".The difference is a colon ( instead of a dot (.) between player and Say. So when calling Events Add, I should use a period but when calling the Say function I should use a Colon? What is the rule for when to use a colon and when to use a period? Events.EveryTenMinutes.Add(sayHello); <-- Use a Period for the ADD method? player:Say("Hello"); <-- Use a Colon for the Say method? Link to comment Share on other sites More sharing options...
blindcoder Posted March 13, 2015 Share Posted March 13, 2015 You use a colon when you are calling a method of an instantiated object (something that has a "self" reference).You use a dot when you use a function stored in a table. I agree that it is not always obvious, and i'm honestly not sure why the Events.*.Add don't have a colon :/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now