project/build/default_html5/main/entername.scriptc
2025-08-25 01:59:20 +01:00

70 lines
No EOL
1.3 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

î function init(self)
msg.post(".", "acquire_input_focus")
go.set_position(vmath.vector3(527.5,348,0), "background")
msg.post("/entername_gui#entername1", "enterthename", { enter = "enter your initials:" })
self.name = ""
msg.post("/entername_gui#entername1", "written_name", { name = self.name })
self.max_char = 3
end
function on_input(self, action_id, action)
if action_id == hash("type") then
if self.max_char > 0 then
self.name = self.name .. action.text
msg.post("/entername_gui#entername1", "written_name", { name = self.name })
self.max_char = self.max_char - 1
elseif self.max_char == 0 then
print("no more characters!!!!!")
end
elseif action_id == hash("backspace") and action.repeated then
self.name = string.sub(self.name, 0, string.len(self.name)-1)
msg.post("/entername_gui#entername1", "written_name", { name = self.name })
self.max_char = self.max_char + 1
if self.max_char > 3 then
self.max_char = 3
end
end
if action_id == hash("enter") then
msg.post("main:/controller#main", "save_name", { name = self.name })
end
if action_id == hash("escape") and action.pressed then
msg.post("main:/controller#main", "escape")
end
end
@main/entername.script"