Scripts / [SOLVED] Why scripts never do anything?

User Offline
Joined: 26th Dec 2022
Posted: 16th Mar 2023 18:53
I'm probably the noobiest person on this forum.

( sorry for the bad english, not my native language )

I have copied dozens of scripts ( ex: small'g scripts ) and none of them never do anything. Example: Today i'm trying to create an object that shows a imagem when press e with the following script:

function show_img_init(e)
LoadImages("scriptbank\\images\\Get to the River\\001.png",1)
i_state[e] = "unhidden"

function show_img_main(e)

PlayerDist = GetPlayerDistance(e)

if PlayerDist < 100 then
if i_state[e] == "unhidden" then
Prompt ("any thing")
if g_KeyPressE == 1 and keypressed == 0 then
keypressed = 1
i_state[e] = "hidden"
end -- g_KeyPressE == 1

elseif i_state[e] == "hidden" then
Prompt ("Press E To hide image")
if g_KeyPressE == 1 and keypressed == 0 then
keypressed = 1
i_state[e] = "unhidden"
end --i_state[e] == {"hidden"}
end -- PlayerDist < 100

if g_KeyPressE == 0 then keypressed = 0 end

end -- main

so, I get this code, create a new lua script with notepad++, paste the code, save as image.lua in script folder
then, open game guru, grab any dinamic entity , put on map, go on properties set as static = no and select the image.lua
Run the game and nothing happens. The object has no prompt

Samething with other scripts, like the mannequin one, that the enemy only follows you if are not looking. Nothing happens.

What the heck I'm doing wrong? I'm using wrongly the scripts?

The author of this post has marked a post as an answer.

Go to answer
GameGuru Master
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Mar 2023 12:32
This post has been marked by the post author as the answer.
The script name has to exactly match the name of the _main function.

i.e. this script needs to be named show_img.lua because the function it provides is called show_img_main.
Been there, done that, got all the T-Shirts!
User Offline
Joined: 26th Dec 2022
Posted: 20th Mar 2023 19:48

You just save me. I never figured that the name of lua file was só important. Thanks a lot

Login to post a reply

Server time is: 2023-03-21 20:29:34
Your offset time is: 2023-03-21 20:29:34